<%@ page import="util.JDBC" %>
<%@ page import="util.JSON" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    //初始化
    response.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    String userId="";
    try{
        userId=session.getAttribute("userId").toString();
    }catch (Exception ex){
        response.sendRedirect("login.jsp");
    }
    //处理请求
    //获取选课课程id
    String courseId=request.getParameter("courseId");
    //创建sql语句
    String sql="delete from student_course\n" +
            "WHERE courseId='"+courseId+"' and studentId='"+userId+"'";
    //测试数据库连接状态
    JDBC.connectionTest();
    //执行sql语句
    JDBC.executeUpdate(sql);
    JSON json=new JSON("status","success");
    json.put("message","退选成功！");
    out.print(json.getJson());
%>